
<div class="panel">
    <div class="panel-heading">
        库存管理
    </div>
    <div class="panel-body">
        <div class="row">
            <div class="col-sm-4">
                <a class="btn btn-primary" href="{:url('add_storage')}"><i class="icon icon-plus"></i> 采购入库</a>
            </div>
            <div class="col-sm-8 mySearch">
                <form class="form-inline" id="searchForm" action="{:request()->url()}">
                    <div class="form-group">
                        <label>关键字：</label>
                        <input type="text" class="form-control" placeholder="名字" name="kw">
                    </div>
                    <button type="submit" class="btn btn-primary">搜索</button>
                </form>
                <script>
                    $('#searchForm').myFormData(<?= json_encode(input('get.'), JSON_UNESCAPED_UNICODE) ?>);
                </script>
            </div>
        </div>
    </div>
    <div class="table-responsive">
        <table class="table table-hover table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th>订单编号</th>
                <th>采购日期</th>
                <th>采购人</th>
                <th>总价</th>
                <th>总数量</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php
            foreach ($list as $i=>$row) {
              $zongjia= \app\member\model\StockStorage::where('orderid',$row['orderid'])->sum('buying_price*amount');
              $amount= \app\member\model\StockStorage::where('orderid',$row['orderid'])->sum('amount');
                ?>
                <tr>
                    <td>{$i+1}</td>
                    <td>{$row.orderid}</td>
                    <td>{$row.addtime}</td>
                    <?php $u= \app\member\model\Member::where('uid',$row['userid'])->find();?>
                    <td>{$u.realname}</td>
                    <td>{$zongjia}</td>
                    <td>{$amount}</td>
                    <td>
                        <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-remote="{:url('show_storage')}?orderid={$row.orderid}">采购清单</button>
                    </td>
                </tr>
                <?php
                }
            ?>
            </tbody>
        </table>
    </div>
</div>

{$list->render()}